﻿using UnityEngine;
using System.Collections;
namespace DevelopTools
{
    public class DestroyUnityObject : MonoBehaviour
    {
        /// <summary>
        /// 需要销毁的对象
        /// </summary>
        private static GameObject gameObjSelf;
        /// <summary>
        /// awake时，传入gameObject
        /// </summary>
        private void Awake()
        {
            gameObjSelf = gameObject;
        }
        /// <summary>
        /// 销毁自身对象
        /// </summary>
        public static void DestroyObj()
        {
            if (gameObjSelf != null)
                DestroyImmediate(gameObjSelf);
        }
        /// <summary>
        /// 销毁对象
        /// </summary>
        /// <param name="obj">传入销毁的对象</param>
        public static void DestroyObj(GameObject obj)
        {
            DestroyImmediate(obj);
        }
        /// <summary>
        /// 销毁对象
        /// </summary>
        /// <param name="obj">传入销毁的对象</param>
        /// <param name="desTime">销毁对象的时间</param>
        public static void DestroyObj(GameObject obj, float desTime)
        {
            Destroy(obj, desTime);
        }
        /// <summary>
        /// 销毁对象
        /// </summary>
        /// <param name="isDone">清除标记</param>
        public static void DestroyObj(bool isDone)
        {

        }
        /// <summary>
        /// 销毁对象
        /// </summary>
        /// <param name="obj">清除的对象</param>
        /// <param name="isDone">清除标记</param>
        public static void DestroyObj(GameObject obj, bool isDone)
        {
            if (isDone)
                DestroyImmediate(obj);
        }
        /// <summary>
        /// 销毁对象
        /// </summary>
        /// <param name="obj">清除的对象</param>
        /// <param name="desTime">时间</param>
        /// <param name="isDone">清除标记</param>
        public static void DestroyObj(GameObject obj, float desTime, bool isDone)
        {
            if (isDone)
                Destroy(obj, desTime);
        }
    }
}